package second;

import java.util.ArrayList;
import java.util.Scanner;

public class Main5 {
     public static void main(String[] args)
     {
    	 Scanner sc=new Scanner(System.in);
    	 ArrayList<String> strList = new ArrayList<String>();
    	 while(true)
    	 {
    		 String s=sc.next();
    		while(!s.equals("!!end!!"))
    		{
    			 strList.add(s);
    			 s=sc.next();
    		 }
    	 strList.add(0,"begin");
    	 strList.add("end");
    	 System.out.println(strList);
         String t=sc.next();
    	 if(strList.contains(t))
    	 {
    	     System.out.println("true"); 
    		 System.out.println(strList.indexOf(t));
    		 System.out.println(strList.lastIndexOf(t));
    	 }
    	  else
    	  {
    		  System.out.println("false");
    		  System.out.println("-1");
    	  }
    	  System.out.println(strList.get(0));
    	  strList.remove(0);
    	  System.out.println(strList);
          String t1=sc.next();
          strList.set(1,t1);
          System.out.println(strList);
          ArrayList<String> strList1=new ArrayList<>();
          String t2=sc.next();
          for (String e:strList)
          {
                  if(e.indexOf(t2)>=0)
                      strList1.add(e);
          }
          System.out.println(strList1);
          int a;
          a=strList.indexOf(t2);
          if(a>=0)
              strList.remove(a);
          System.out.println(strList);
          strList.clear();
          System.out.println(strList+" "+strList.size()+","+strList.isEmpty());
      }

     }
     }



